package com.itheima.tlias84.controller;

import com.alibaba.fastjson2.JSONObject;
import com.itheima.tlias84.utils.ResultUtil;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("session")
public class TestSessionController {


    @GetMapping("save")
    public ResultUtil saveSession(HttpSession session) {
        session.setAttribute("username", "summer");
        session.setAttribute("password", "123456");
        Object username = session.getAttribute("username");
        Object password = session.getAttribute("password");
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("username", username);
        jsonObject.put("password", password);
        return ResultUtil.success(jsonObject);
    }
}
